<template>
    <div style="background-color: #c5ffe7">
        <span>
            软件登记
        </span>
    <el-divider></el-divider>
    <el-form ref="patentRef" :model="patentInfo" label-width="400px">
        <el-form-item label="专利名称" style="width:900px">
            <el-input v-model="patentInfo.patentname"></el-input>
        </el-form-item>
        <el-form-item label="专利类型">
            <el-select v-model="patentInfo.patentType" placeholder="请选择专利类型" style="width:500px">
                <el-option label="实用性专利" value="实用性专利"></el-option>
                <el-option label="发明专利" value="发明专利"></el-option>
                <el-option label="外观设计专利" value="外观设计专利"></el-option>
            </el-select>
        </el-form-item>
        <!--<el-form-item label="专利号" style="width:900px">
            <el-input v-model="patentInfo.spNumber"></el-input>
        </el-form-item>-->
        <!--<el-form-item label="申请人" style="width:900px">
            <el-input v-model="patentInfo.spApplyName"></el-input>
        </el-form-item>-->
        <el-form-item label="发明人" style="width: 900px">
            <el-input type="textarea" v-model="patentInfo.inventors"></el-input>
        </el-form-item>
        <el-form-item label="申请日期" >
            <el-col :span="11" style="width:500px">
                <el-date-picker type="date" placeholder="选择日期"  value-format="yyyy-MM-dd"  v-model="patentInfo.applytime"
                                style="width: 100%;"></el-date-picker>
            </el-col>
        </el-form-item>
        <el-form-item label="地址" style="width: 900px">
            <el-input type="textarea" v-model="patentInfo.address"></el-input>
        </el-form-item>
       <!-- <el-form-item label="专利有效期" style="width:900px">
            <el-input v-model="patentInfo.times"></el-input>
        </el-form-item>-->
        <el-form-item label="专利有效期">
            <el-select v-model="patentInfo.times" placeholder="请选择" style="width:500px">
                <el-option label="3年" value="3"></el-option>
                <el-option label="5年" value="5年"></el-option>
                <el-option label="10年" value="10年"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="描述" style="width: 900px">
            <el-input type="textarea" v-model="patentInfo.pdescribe"></el-input>
        </el-form-item>

        <el-form-item style="padding-left: 150px">
            <el-button type="primary" @click="onSubmit">提交申请</el-button>
            <el-button @click="backHome">取消</el-button>
        </el-form-item>
    </el-form>
    </div>
</template>

<script>
    export default {

        data() {
            return {
                patentInfo: {
                    patentID:'18',
                    patentname: '',
                    patentType: '',
                    patenter: '',
                    inventors:'',
                    applytime:'',
                    times:'',
                    address:'',
                    pdescribe:'',
                    jftime:'212',//缴费日期
                    sqtime:'121',//授权日期
                }
            }
        },
        created() {
            this.patentInfo.patenter = window.sessionStorage.getItem('username')
        },
        methods: {
            /*onSubmit() {
                this.$refs.patentRef.validate(async valid => {
                    console.log(this.patentInfo);
                    if (!valid) return;
                    const {data:resString} = await this.$http.post("addPatent",this.patentInfo);//②接收后台返回的string数据：含有两块内容--flag和student <--| = |--> ①访问后台
                    var res=JSON.parse(JSON.stringify(resString));//转换为json对象
                    console.log(res);
                    if(res=="ok"){
                        this.$message.success("注册成功");
                        await this.$router.push({path: "/home"});
                    }else{
                        this.$message.error("注册失败");
                    }
                })
            },*/
            onSubmit() {
                console.log(this.patentInfo);
                this.$refs.patentRef.validate(async valid => {
                    console.log(this.patentInfo);
                    if (!valid) return;
                    const {data:resString} = await this.$http.post("addPatents",this.patentInfo);//②接收后台返回的string数据：含有两块内容--flag和student <--| = |--> ①访问后台
                    var res=JSON.parse(JSON.stringify(resString));//转换为json对象
                    console.log(res);
                    if(res=="ok"){
                        this.$message.success("申请成功");
                        await this.$router.push({path: "/SoftwareRegister"});
                    }else{
                        this.$message.error("申请失败");
                    }
                })
            },
            backHome(){
                this.$router.push("/SoftwareRegister");
            }
        }
    }
</script>

<style scoped>
</style>
